<script setup lang="ts">
import { ref } from 'vue'
import type { IRomInfo } from '@/types'

defineProps<{ item: IRomInfo }>()

//鼠标移入显示截图
let isHover = ref(false)
</script>

<template>
  <el-card
    class="el-card"
    @click="$router.push({ path: '/play', query: { id: item.id } })"
    @mouseover="isHover = true"
    @mouseleave="isHover = false"
    :body-style="{ padding: '0' }"
  >
    <img :src="isHover ? item.image : item.cover" alt="cover" class="img" />
    <el-row justify="center">
      <el-col :span="15">
        <p class="footer">{{ item.title }}</p>
      </el-col>
      <el-col :span="7" class="tags">
        <el-tag>{{ item.category }}</el-tag>
      </el-col>
    </el-row>
  </el-card>
</template>

<style lang="scss" scoped>
.el-card {
  border-radius: 10px;
  .img {
    width: 100%;
    height: 140px;
  }
  .footer {
    width: 90%; /*一定要设置宽度，或者元素内含的百分比*/
    overflow: hidden; /*溢出的部分隐藏*/
    white-space: nowrap; /*文本不换行*/
    text-overflow: ellipsis; /*ellipsis:文本溢出显示省略号（...）；*/
  }
  .tags {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}
</style>
